import React, { useState, useEffect } from 'react';
import axios from 'axios';
export default function (props) {
  const [state, setState] = useState();

  useEffect(() => {}, []);

  const btnMock1 = () => {
    axios.get('/api/index').then((res) => {
      console.log('res', res.data);
    });
  };

  const btnMock2 = () => {
    //  post 请求的数据
    axios.post('/api/index1', { a: 1, b: 2 }).then((res) => {
      console.log('res:', res.data);
    });
  };

  const btnMock3 = () => {
    //  post 请求的数据
    axios.get('/api/index3', { a: 1, b: 2 }).then((res) => {
      console.log('res:', res.data);
    });
  };

  return (
    <div>
      mock 数据
      <button onClick={btnMock1}> 请求 mock 数据 get </button>
      <button onClick={btnMock2}> 请求 mock 数据 post </button>
      <button onClick={btnMock3}> 请求 mock 数据 get 使用mockjs 库 </button>
    </div>
  );
}
